#include <stdio.h>
#include <math.h>
int hammingWeight(int n) {
       int count = 0;
       while(n != 0)
       {
           n = n & (n - 1);
           count ++;
       }
       return count;
}
int hammingDistance(int x, int y){
        int z,count=0;
        z = x ^ y;
        while(z != 0)
        {
            z = z & (z - 1);
            count++;
        }
        return count;
}
int add(int a, int b){
    while(b != 0)
    {
    	int c = (a & b) <<1;
    	a = a ^ b;
		b = c; 
	}
    return a;
}
int singleNumber(int* nums, int numsSize){
        int ans = nums[0], i;
        for(i = 1; i < numsSize; i++)
        {
        	ans = ans ^ nums[i];
		}
		return ans;
}
int th(int* nums, int size)
{
	int max = 0, i, k = 0,j,s=0;
	for(i = 0; i < size; i++)
	{
		if(max < nums[i])
		max = nums[i];
	}
	
	while(pow(2,k) <= max)
	k++;
	
	int num[k]={0};
	for(i = 0; i < size; i++)
	{
		for(j = 0; j <= k; j++)
		{
			num[j]+=(nums[i] & 1);
			nums[i] >> 1;
		}
	}
	for(i = 0; i <= k; i++)
	{
		num[i] = num[i] % 3;
		if(num[i] == 1)
		s += pow( 2, i);
	}
	return s;
	
}


